import os
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

if os.path.exists('summary.db'):
    os.remove('summary.db')

engine = create_engine('sqlite:///summary.db', echo=True)

Base = declarative_base()


class Summary(Base):
    __tablename__ = 'summary'

    id = Column(Integer, primary_key=True)
    trial = Column(Integer)
    frame = Column(Integer)
    load = Column(Integer)
    loss = Column(Integer)


Base.metadata.create_all(engine)

DBSession = sessionmaker(bind=engine)

session = DBSession()
sum1 = Summary(trial=1, frame=64, load=10, loss=1)
sum2 = Summary(trial=1, frame=64, load=20, loss=1)
sum3 = Summary(trial=1, frame=60, load=10, loss=100)
sum4 = Summary(trial=1, frame=60, load=20, loss=100)
sum5 = Summary(trial=1, frame=1519, load=10, loss=90)
sum6 = Summary(trial=1, frame=1519, load=20, loss=90)
sum7 = Summary(trial=2, frame=64, load=10, loss=1)
sum8 = Summary(trial=2, frame=64, load=20, loss=1)
sum9 = Summary(trial=2, frame=60, load=10, loss=100)
sum10 = Summary(trial=2, frame=60, load=20, loss=100)
sum11 = Summary(trial=2, frame=1519, load=10, loss=90)
sum12 = Summary(trial=2, frame=1519, load=20, loss=90)

session.add(sum1)
session.add(sum2)
session.add(sum3)
session.add(sum4)
session.add(sum5)
session.add(sum6)
session.add(sum7)
session.add(sum8)
session.add(sum9)
session.add(sum10)
session.add(sum11)
session.add(sum12)

session.commit()
session.close()
